package aex.action;

import java.io.File;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import aex.util.CU;

@Controller("PublicAction")
@Scope("prototype")
public class PublicAction extends BaseActon{

	private static final long serialVersionUID = 1L;

	
	public PublicAction() {
		CU.deBugPrintln("PublicAction 被创建");
	}

	/**
	 * 向客户端返回一个随机的验证码。
	 * 
	 * @return
	 */
	public String getYzm() {
		CU.sendVerificationCode(response, request, 120, 35);
		return null;
	}

	/**
	 * 上传头像
	 * @return
	 */
	public String uploadHead(){
		String path=CU.writeFile(file1, 
				"head", 
				file1FileName,
				request.getContextPath());
		ajaxPrint("<script type='text/javascript'>window.parent.document.getElementById('targerImg').setAttribute('src', '"+path+"');</script><a>上传成功，请关闭当前窗口！</a>");
		return null;
	}

	
	
	private File file1;
	private String file1FileName;
	private String file1ContentType;

	public File getFile1() {
		return file1;
	}

	public void setFile1(File file1) {
		this.file1 = file1;
	}

	public String getFile1FileName() {
		return file1FileName;
	}

	public void setFile1FileName(String file1FileName) {
		this.file1FileName = file1FileName;
	}

	public String getFile1ContentType() {
		return file1ContentType;
	}

	public void setFile1ContentType(String file1ContentType) {
		this.file1ContentType = file1ContentType;
	}


}
